local  Widget = require "widgets/widget"
local Text = require "widgets/text" 
local UIAnim = require "widgets/uianim"

local P1 = {135/255,206/255,235/255,1.0}  --天蓝色
local P2 = {1, 1, 1, 1}

--文本
local function AddText(inst,str,data)
    data = data or {}
    data.font = data.font or CHATFONT       --BODYTEXTFONT
    data.size= data.size or 34
    data.corlour = data.corlour or UICOLOURS.BLACK
    data.pos = data.pos or {0,0}
    local t = inst:AddChild(Text(data.font,data.size,str,data.corlour))
    t:SetPosition(data.pos[1],data.pos[2])
    return t 
end

local i9ow3_hud = Class(Widget, function(self, owner)
	Widget._ctor(self, "i26spui")
    self.owner = owner 

    self.root = self:AddChild(Widget())
    self.root:SetPosition(0,0)

    self.title = self.root:AddChild(Text(HEADERFONT, 38, "0", P2))
    self.title:SetPosition(-48,0)
    self.lvtext = self.root:AddChild(Text(HEADERFONT, 32, "/", P2))
    self.lvtext:SetPosition(-24,0)

    self.anim = self:AddChild(UIAnim())

    self.anim:GetAnimState():SetBank(TUNING.LINKAGE.SPARKLE and "i26spui_sparkle" or "i26spui")
    self.anim:GetAnimState():SetBuild("i26spui")
    self.anim:GetAnimState():SetScale(0.2,0.2,0.2)
    self.anim:SetClickable(false)

    self.inst:DoTaskInTime(0,function()
        self.owner:ListenForEvent("i26spdelta", function(owner, data)
            if not data or not data.point then return end 
            self:LvCh(data.point)
        end)
        if self.owner.replica.i26skill then
            self:LvCh(self.owner.replica.i26skill:GetPoint())
        else
            self:LvCh(0)
        end
    end)
    
end)

local Anat = {
    [1] = "anim1",
    [2] = "anim2",
    [3] = "anim3",
    [4] = "anim4",
    [5] = "anim5",
    [6] = "anim6",
    [7] = "anim7",
}

function i9ow3_hud:LvCh(num)
    if not num then return end 
    if Anat[num] ~= nil then
        self.anim:GetAnimState():PlayAnimation(Anat[num])
    else
        self.anim:GetAnimState():PlayAnimation("anim0")
    end
    self.title:SetString(num)
end


return i9ow3_hud
